package staticdemo;

/**
 * Created by Veronica on 2017/3/29.
 */

class Person{
    String name;
    private static String country = "北京";//声明为静态即是大家共有属性

    public Person(String name){
        this.name = name;
    }

    public static void setCountry(String country){
        Person.country = country;
    }
    public static String getCountry(){
        return country;
    }

    public void tell(){
        System.out.println("姓名："+name+ " 出生地："+country);
    }
}
public class StaticDemo01 {
    public static void main(String args[]){
        Person p1 = new Person("张三");
//        Person.country = "上海";
        Person.setCountry("上海");
        p1.tell();

        Person p2 = new Person("李四");
//        p1.country = "上海";
        p2.tell();

        Person p3 = new Person("王五");
//        p1.country = "上海";
        p3.tell();
    }
}
